def binary_search(val, li):
    left, right = 0, len(li) -1
    while left<=right:
        mid = (left+right) // 2
        if li[mid] == val:
            return mid
        elif li[mid] < val:
            left = mid+1
        else:
            right -= 1
    return None

if __name__ == '__main__':
    li = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
    print(binary_search(5, li))
